package com.runda.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bbjob.mapper.QueChoiceMapper;
import com.bbjob.mapper.QueOperationMapper;
import com.bbjob.mapper.QuestionBankMapper;
import com.bbjob.mapper.SysOrganizationStuMapper;
import com.bbjob.mapper.UserMapper;
import com.bbjob.model.QuestionBank;
import com.runda.service.ICountService;

import tk.mybatis.mapper.entity.Example;

@Service
public class CountServiceImpl implements ICountService {

	@Resource
	private UserMapper usermapper;
	@Resource
	private QuestionBankMapper bankmapper;
	@Resource
	private QueChoiceMapper choicemapper;
	@Resource
	private QueOperationMapper operationmapper;
	@Resource
	private SysOrganizationStuMapper stumapper;

	@Override
	public Map<String, Object> homepageCount() {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String, Object>();
		// 系统注册量
		map.put("UserCount", usermapper.selectAll().size());
		// 考生数量
		map.put("StuCount", stumapper.selectAll().size());
		// 试卷数量
		Example ex = new Example(QuestionBank.class);
		Example.Criteria c = ex.createCriteria();
		c.andEqualTo("isDelete", 0);
		map.put("bankCount", bankmapper.selectByExample(ex).size());
		// 试题数量
		map.put("questionCount", operationmapper.selectQueOperationWithBank(new ArrayList<String>(), null, null, null, null, null, null, null, null).size() + choicemapper.selectQueChoiceWithBank(new ArrayList<String>(), null, null, null, null, null, null, null, null, null).size());
		return map;
	}

}
